﻿<!-- 文档类型声明 -->
<!DOCTYPE html> 
<!-- 文档使用中文 -->                 
<html lang = "zh-cn">
  <head>
	<!-- 网页标题 -->
    <title>密码找回</title>
	<!-- 设置当前文档的编码格式 -->
	<meta charset = "utf-8">
	<!-- 设置IE浏览器的解析模式 -->
	<meta http-equiv = "X-UA-Compatible" content = "IE=edge">
	<!-- 设置视窗 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 1.加载Bootstrap的层叠样式表 -->
    <link rel="stylesheet" href="<?php echo base_url();?>/public/css/bootstrap.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
        <script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
	<script type = "text/javascript">
		function mygetObject(id){
			return document.getElementById(id);
		}
		function getXmlHttpObject(){
			var xmlHttpRequest;
			if(window.ActiveXObject){
				xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
			}
			else{
				xmlHttpRequest=new XMLHttpRequest();
			}
			return xmlHttpRequest;
		}
		var myXmlHttpRequest;
		function sendinfo(){
			myXmlHttpRequest = getXmlHttpObject();
			if(myXmlHttpRequest){
				var url = "<?php echo site_url('login/findword'); ?>";
				var data = "username="+mygetObject('username').value+"&question="+mygetObject('question').value+"&answer="+mygetObject('answer').value;
				myXmlHttpRequest.open("post",url,true);
				myXmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				myXmlHttpRequest.onreadystatechange=process;
				myXmlHttpRequest.send(data);
			}
		}
		function process(){
			if(myXmlHttpRequest.readyState == 4 && myXmlHttpRequest.status == 200){
		        var mes = myXmlHttpRequest.responseText;
				var res_object = eval("("+mes+")");
				if(res_object.tips != ''){
					alert(res_object.tips);
				}else{
					mygetObject('question').value = res_object.question;
				}
			}
		}
		var myObject;
		function sendansw(){
			myObject = getXmlHttpObject();
			if(myObject){
				var url = "<?php echo site_url('login/checkanswer'); ?>";
				var data = "username="+mygetObject('username').value+"&question="+mygetObject('question').value+"&answer="+mygetObject('answer').value;
				myXmlHttpRequest.open("post",url,true);
				myXmlHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				myXmlHttpRequest.onreadystatechange=proc;
				myXmlHttpRequest.send(data);
			}
		}
		function proc(){
			if(myXmlHttpRequest.readyState == 4 && myXmlHttpRequest.status == 200){
		        var mes = myXmlHttpRequest.responseText;
				var res_object = eval("("+mes+")");
				if(res_object.info != ''){
					alert(res_object.info);
				}
			}
		}
	</script>
  </head>
  <body>
    <br><br><br><br>
    <div class = "well col-sm-offset-3 col-sm-5">
	
    <form class = "form-horizontal" action = "<?php echo site_url('login/findword');?>">
	
	    <h3 class = "text-info col-sm-offset-4">密码找回</h3>
	
		<center><div class = "form-group">
			<label class = "col-sm-4 control-label" for = "username">用户名：</label>
			<div class = "col-sm-4">
				<input type = "text" class = "form-control" id = "username" placeholder = "用户名">
			</div>
		</div>
		
		
		<div class = "form-group">
			<label class = "col-sm-4 control-label" for = "question">密保问题：</label>
			<div class = "col-sm-4">
				<input type = "text" class = "form-control" id = "question">
			</div>
		</div>
		
		<div class = "form-group">
			<label class = "col-sm-4 control-label" for = "answer">密保答案：</label>
			<div class = "col-sm-4">
				<input type = "text" class = "form-control" id = "answer" placeholder = "密保答案">
			</div>
		</div>
		
	    <div class = "col-sm-offset-2 col-sm-1">
			<a href = "#" type = "submit" class = "btn btn-default" role = "button" onclick = "sendinfo();">找回</a>
		</div>
		
		<div class = "col-sm-offset-3 col-sm-1">
			<a href = "#" type = "submit" class = "btn btn-default" role = "button" onclick = "sendansw();">提交</a>
		</div>
		
	
	</form>
	</div>
    <!-- 2.加载jQuery库，同时加载该库必须在加载bootstrap.min.js之前 -->
    <script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
    <!-- 3.加载bootstrap的核心js库 -->
    <script src="<?php echo base_url();?>/public/js/bootstrap.min.js"></script>
  </body>
</html>